home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
007
/
d86v311a.arc
/
02DEM.DOC
< prev
next >
Wrap
Text File
|
1987-09-25
|
12KB
|
232 lines
CHAPTER 2 D86 DEMONSTRATION 2-1
To demonstrate some of the powers of D86, let's walk through a
D86 session. You should print out a copy of this chapter (file
02DEM.DOC) and also the file HEXOUT.8. Using those listings, go
through the following steps. You may wish to check them off as
you go through them, to keep track of where you are.
1. Make sure your current directory contains all the files
A86.COM, D86.COM, and HEXOUT.8.
2. Assemble the HEXOUT program by typing the command A86
HEXOUT.8. The A86 assembler will create the files HEXOUT.COM
and HEXOUT.SYM. Look over the listing of the program, to get
acquainted with what it does.
3. Now comes the moment of truth, especially if you do not have a
real IBM-PC. Find out if the debugger works on your machine,
by typing the command D86 HEXOUT 41 42 5A.
If all goes well, the screen should blank; and the D86
debugger screen should appear. The blinking cursor should be
at the bottom left. A sign-on message should appear at the
upper right. A disassembly of the HEXOUT program should be in
the upper left. The label HEXOUT should appear on the first
line, followed on the second line by the address 0100 and the
instruction MOV SI,TAIL_BUFF. To the left of the address
should be a reverse-video pound sign. If you don't see all of
these things, refer to Chapter 3 to initiate actions to let me
know how I might fix the problem.
4. Let's look at what we already have. Notice the display of
register values in the lower left corner. The values are all
4-digit hexadecimal. At the top of the second column of
registers is a sequence of lower-case letters. This is the
flags display. Each small letter stands for a flag whose
value is currently TRUE. The flags settings are those that
were handed to D86 by the operating system starting the
program; for MSDOS V3,1, the settings are "i z e". That
display indicates that the interrupt flag "i", the zero flag
"z", and the parity-even flag "e" are all TRUE; the other
flags are FALSE. To the right of the registers are six lines
labelled 1: through 6:. These are the memory window lines.
Since you haven't specified any memory windows yet, they
contain nothing but their numbers. Below the memory-window
lines is a line labelled 0:. This is the stack display line.
The number 0: gives the number of words on the stack,
currently zero because nothing has been pushed onto the stack.
2-2
5. Observe that the sign-on message tells you to press Alt-F10
for help. Do so (that is, hold down the Alt-key while
pressing the F10 key). You are now in help-mode, where you
will remain until you press Alt-F10 again. D86 will keep
changing the help-window, depending on what it thinks you are
doing. Right now you have a summary of the main function-keys,
plus a few other things. Press F10 (without the Alt), and
you'll get a summary of one-letter debugger commands. Press
F10 a second time and you'll get a summary of Ctrl-key
commands. Finally, press F10 a third time to return to the
function-key help screen.
6. Let's try an immediate assembly-language instruction. Press
the "M" key. Note that the reverse-video block jumps from the
pound-sign within the disassembly, down to the line just above
the blinking cursor. The block is the debugger's cursor; the
blinking cursor is the program's console output cursor. The
debugger does not use the blinking cursor because we do not
want the program's output to interfere with the debugger's
output. Also note that the help-window is now telling you
that you are typing in an assembly-language line.
7. Complete the line MOV AX,123. The debugger immediately
executes the assembly language line you just typed, setting
the register AX. Note that you did not have to learn a
debugger command for setting registers; if you know A86, you
already know how to set registers! The value of AX is now
007B, which may surprise you if you expected 0123. A86's
default base is 10, so 123 was taken as decimal; which is hex
7B. Type MOV AX,0123 instead, to get a value of hex 123.
8. Let's now play with the flags display. Type the line ADD
AL,05D, which changes AL (the last two digits of AX) to hex
80, and alters the flags to "o is a ". The interrupt flag is
still on; but zero and parity-even are now off. They have
been replaced by "o" overflow, "s" sign, and "a" auxiliary
carry.
9. Type the line consisting of just CMC. This is the Complement
Carry instruction. Observe that the "c" appears. Notice also
that the CMC that you typed remains on the screen. Notice on
the help window the entry "F3 RepeatCmd". This tells you that
the F3 key will repeat the last line-command (not function-
key) that you typed. Press F3 several times, to see the carry
flag toggle on and off. Isn't that the cleanest flags display
you've ever seen?
2-3
10. Let's single-step an instruction. Press the F1 key. This
executes the program instruction, loading the SI register with
TAIL_BUFF. The disassembly cursor moves down to the next
instruction. Observe that SI has changed to 0081, which is
the pointer to the invocation command-tail, which should
contain the string typed after HEXOUT: " 41 42 5A" followed by
a carriage-return code (hex 0D).
11. Let's examine memory to verify that last assertion. Press
the "1" key. The cursor jumps to the start of memory-window 1,
and the help-window gives you a huge choice of memory types to
display. The entry "ByteHex 2" tells us that "B" will cause
hex bytes to be displayed. The "2" indicates that the display
occupies a fixed number of display bytes for every memory
unit, namely 2 hex digits. Type B followed by a comma, to
indicate that you want nothing but hex bytes to be displayed.
Now the help window asks for a segment location. Let's use
the DS register: type DS followed by a comma. Now the help
window wants an offset within the segment: type SI. Before
typing the terminating ENTER, backspace-out what you have
typed, and watch the help-windows regress appropriately.
Isn't that impressive? Now retype the line, "B,DS,SI". Note
that when you press ENTER, the line fills out with hex values:
20 34 31 20 34 32 20 35 41 0D etc. (61 instead of 41 is OK;
it means you typed the invocation in lower-case.)
12. Let's look at the same line, displayed as text. Type "2",
moving to memory line 2, then type the line "T,SI". This time
you specified type T for text, and you left out the segment-
register specification. D86 uses DS when you leave out the
segment register; so in this case you'll get the same segment.
This time the display starts with "41 42 5AM"; the "M" is the
carriage-return, which is control-M, ambiguously displayed.
You can read Chapter 6 later on for descriptions of all the
types, including other text types allowing non-ambiguous
displays.
13. Let's execute the next instruction, CALL GET_HEX. Here we
have a choice, between executing the procedure all at once, or
stepping into the procedure to execute its instructions one at
a time. Let's try stepping in first: type the F1 key. The
cursor jumps to location GET_HEX, on the same disassembly
screen. The SP register decrements from FFFE to FFFC, and a
value 0106 appears on the stack. This is the return address,
pointing to the instruction following CALL GET_HEX.
14. Watch memory lines 1 and 2 as you press F1 again, single-
stepping the LODSB instruction. You had set up the lines to
be pointed to by SI. Since SI changes when LODSB is executed,
the memory-displays advance to the next byte. Note that the AL
register contains the value hex 20, a blank.
2-4
15. In a normal debugging session, we would continue stepping
within GET_HEX, but let's not do that right now. Instead,
press the F6 "TrapRet" key, which starts the program going,
trapping at the return address on top of the stack, which was
0106. The cursor jumps back up to location 0106, the value is
no longer on the stack, and SI and the memory-displays have
advanced to 0084.
16. Let's try the classic "G" command, common to all debuggers.
Type the line "G,0103", noticing the help-windows as you go
along. After you press ENTER, the program runs until it gets
back to the trap address you provided, 0103. Note that the
program has called OUT_VALUE to output the "A" that
corresponds to your input hex 41. The "A" appears on the
bottom line, and the blinking cursor advances.
17. Let's execute the next CALL GET_HEX all at once, by pressing
the F2 ProcStep key. SI advances again, and AL is loaded with
the next value 42.
18. Notice that the disassembly is symbolic: the display is CALL
GET_HEX, not CALL 0112 as lesser debuggers might give you.
Let's try symbolic input: type the line "B,HEX_DIGIT?",
causing the debugger to set a fixed trap at location
HEX_DIGIT?. Now set your program running with a simple G
followed by the ENTER key. The program traps at HEX_DIGIT?.
Since this location is not in the disassembly window, the
window is regenerated, and the cursor placed at HEX_DIGIT?.
The memory displays now point to the final number "5A".
19. Press F3 to repeat the G-command. The program traps at
HEX_DIGIT? again, with SI advanced to the "A". Press F3
again; advancing SI to the final carriage-return.
20. Press F3 yet again. Since HEX_DIGIT? is never reached again,
the program runs to its completion. D86 automatically traps
at the EXIT instruction: in this case, it is INT 021 with the
AH register set to hex 4C, the function number for EXIT. If
we try to start the program again from here, we will be frozen
here: we must issue the Q command to exit the session. Don't
do it yet, though.
21. Before exiting, let's check out HEX_DIGIT? more thoroughly.
First, we clear the breakpoint we set, by typing "B" followed
by the ENTER key.
22. Type the command line "J 0200", jumping to a scratch-pad
memory area. Then press the F7 key, entering Patch Memory
mode. The cursor moves into the disassembled instruction,
signalling that whatever you type is clobbering it.
2-5
23. Type in the lines "INC BL", "MOV AL,BL", and "JMP
HEX_DIGIT?". Press ENTER at the beginning of the fourth line,
exiting Patch Memory mode. The cursor will return to the left
of the 0200 INC BL line.
24. Type the immediate command "MOV BL,'0'-2". The BL register
should change to the evaluated value, hex 2E.
25. Execute the patch-subroutine by typing the line "CALL 0200".
The value BL increments to 2F, which is one less than the
lowest digit, '0'. The Carry flag is set, indicating that
HEX_DIGIT? has correctly judged 2F not to be a hex digit. Now
press F3 repeatedly, executing your patched subroutine for
each decimal digit. The "c" will disappear as the values
advance; and AL will hold the correct binary value for each
hex digit BL. When BL reaches 3A, the "c" comes back on
again, indicating that we are beyond the decimal digits. When
BL reaches 41, "c" goes off, and AL values of 10 through 15
are displayed. When BL reaches "47" "c" comes on yet again,
because G is not a decimal digit. Type "MOV BL,05F", followed
by "CALL 0200", followed by F3 several more times to verify
correct action for the range of lower-case 'a' through 'f'.
You have, relatively quickly, done a thorough test of
HEX_DIGIT?. How long would that have taken on a lesser
debugger?
26. Type Q followed by ENTER to exit the debugger.